#include "scene.h"
#include "ggl.h"
#include "misc.h"
#include "Glm\glm.hpp"
#include "Glm\ext.hpp"
#include "ground.h"
#include "model.h"
#include "vertexbuffer.h"
#include "shader.h"


void scene::Init()
{
	mCameraPos = glm::vec3(10.0,10.0,10.0);
	viewMatrix = glm::lookAt(glm::vec3(0.0, 0.0, -10.0), glm::vec3(0.0, 0.0, 0.0), glm::vec3(0.0, 1.0, 0.0));
	camera = new Camera();
	m_pSkyBox = new SkyBox();
	//camera->SetPosition(0.0, 0.0, -1.0);
	mModel = new model();
	mModel->Init("res/model/Sphere.obj");
	mModel->SetTexture("..\\Models\\res\\image\\earth.bmp");
	mModel->SetPosition(0.0f, 0.0f, 0.0f);

	m_pSkyBox->Init("res/image/");

}
void scene::SetViewPortSize(float width, float height) {

	
	projectionMatrix = glm::perspective(60.0f, width / height, 0.1f, 10000.0f);
}
void scene::Draw() {
	float  frametime = GetFrameTime();
	glClearColor(0.1f, 0.4f, 0.6f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	camera->Update(frametime, viewMatrix);
	m_pSkyBox->Draw(0, 0, 0, viewMatrix, projectionMatrix);
	mModel->Draw(viewMatrix, projectionMatrix,0, 0,0);

}

void scene::OnKeyUp(char code)
{
}

void scene::OnKeyDown(char code)
{
}

void scene::OnMouseMove(float deltx, float delty)
{
	camera->OnMouseMove(deltx, delty);

}

void scene::OnMouseWheel(float deltz)
{
}

Camera* scene::GetCamera()
{
	return camera;
}

scene::scene():camera(NULL)
{
	
}

scene::~scene()
{
}
